package com.jwthhealth_pub.old.report.base;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

@SuppressWarnings("deprecated")
public abstract class ReprotBaseActivity extends AppCompatActivity {

    private boolean isToast = true;

    @Override
    protected void onCreate( Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//            getWindow().getDecorView().setSystemUiVisibility(ViewHolder.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | ViewHolder.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
//        }

//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//                Window window = getWindow();
//                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
//                window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
//                window.setStatusBarColor(Color.TRANSPARENT);
//                window.setNavigationBarColor(Color.TRANSPARENT);
//            } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
//                Window window = getWindow();
//                window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//
//                ViewGroup mContentView = (ViewGroup) findViewById(Window.ID_ANDROID_CONTENT);
//                View statusBarView = mContentView.getChildAt(0);
//                //移除假的 ViewHolder
//                if (statusBarView != null && statusBarView.getLayoutParams() != null &&
//                        statusBarView.getLayoutParams().height == getStatusBarHeight()) {
//                    mContentView.removeView(statusBarView);
//                }
//                //不预留空间
//                if (mContentView.getChildAt(0) != null) {
////                    ViewCompat.setFitsSystemWindows(mContentView.getChildAt(0), false);
//                    if (statusBarView != null)
//                    statusBarView.setFitsSystemWindows(false);
//                }
//            }
//        }
    }//

    protected abstract void title();


    public void toas(final String msg) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (isToast) {
                    Toast.makeText(ReprotBaseActivity.this, msg, Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        title();
    }

    private int getStatusBarHeight(){
        int result = 0;
        int resId = getResources().getIdentifier("status_bar_height","dimen","android");
        if(resId>0){
            result = getResources().getDimensionPixelSize(resId);
        }
        return result;
    }
}
